/*
 ------------------------------------------------------------------------------
 Copyright (C) 2013 Eternal Games.

 This file is part of the EternalTech source code.

 The EternalTech source code is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or (at your
 option) any later version.

 The EternalTech source code is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 more details.

 You should have received a copy of the GNU General Public License along with
 the EternalTech source code; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 ------------------------------------------------------------------------------
*/


//
// gui_def.cpp - GUI definition parsing and loading
//


#include "gui_local.h"


#define GUIS_HASH_SIZE					(MAX_GUIS >> 2)

static gui_t *				gui_guisHashTable[GUIS_HASH_SIZE];
static gui_t *				gui_guis[MAX_GUIS];
static int					gui_numGUIs;


/*
 ==============================================================================

 GUI PARSING

 ==============================================================================
*/


/*
 ==============================================================================

 GUI LOADING

 ==============================================================================
*/


/*
 ==================
 
 ==================
*/
static gui_t *GUI_Create (const char *name){

	return NULL;
}

/*
 ==================
 
 ==================
*/
static void GUI_Finish (gui_t *gui){

}

/*
 ==================
 
 ==================
*/
static void GUI_Optimize (gui_t *gui){

}

/*
 ==================
 
 ==================
*/
static gui_t *GUI_Load (gui_t *gui){

	return NULL;
}

/*
 ==================
 GUI_Find
 ==================
*/
gui_t *GUI_Find (const char *name){

	gui_t	*gui;
	uint	hashKey;

	// See if already loaded
	hashKey = Str_HashKey(name, GUIS_HASH_SIZE, false);

	for (gui = gui_guisHashTable[hashKey]; gui; gui = gui->nextHash){
		if (!Str_ICompare(gui->name, name))
			return gui;
	}

	// Create the GUI
	gui = GUI_Create(name);

	// Load it in
	return GUI_Load(gui);
}

/*
 ==================
 GUI_Register
 ==================
*/
gui_t *GUI_Register (const char *name){

	return GUI_Find(name);
}


/*
 ==============================================================================

 CONSOLE COMMANDS

 ==============================================================================
*/


/*
 ==================
 
 ==================
*/
static void GUI_ListGUIs_f (){

}

/*
 ==================
 
 ==================
*/
static void GUI_ReloadGUI_f (){

}


/*
 ==============================================================================

 DEFAULT GUIS

 ==============================================================================
*/


/*
 ==================
 
 ==================
*/
void GUI_CreateDefaultGUIs (){

}


/*
 ==============================================================================

 INITIALIZATION & SHUTDOWN

 ==============================================================================
*/


/*
 ==================
 GUI_InitGUIs
 ==================
*/
void GUI_InitGUIs (){

	// Add commands
	Cmd_AddCommand("listGUIs", GUI_ListGUIs_f, "Lists loaded GUIs", NULL);
	Cmd_AddCommand("reloadGUI", GUI_ReloadGUI_f, "Reloads an GUI", Cmd_ArgCompletion_GUIName);

	// Create the default GUIs
	GUI_CreateDefaultGUIs();
}

/*
 ==================
 GUI_ShutdownGUIs
 ==================
*/
void GUI_ShutdownGUIs (){

	// Remove commands
	Cmd_RemoveCommand("listGUIs");
	Cmd_RemoveCommand("reloadGUI");

	// Clear GUI list
	Mem_Fill(gui_guisHashTable, 0, sizeof(gui_guisHashTable));
	Mem_Fill(gui_guis, 0, sizeof(gui_guis));

	gui_numGUIs = 0;
}